<?php
/**
 *
 *
 * @author Zeon <scplay@gmail.com>
 * @date 2018/6/13 13:52
 * @copyright PanxSoft Inc.
 */

namespace App\Services\AliYun;

use OSS\OssClient;

class OSS
{
    /**
     * @var OssClient
     */
    protected $client;

    /**
     * OSS constructor.
     *
     * @throws \OSS\Core\OssException
     */
    public function __construct()
    {
        require_once(base_path('../dw-oc/admin/config.php'));

        // 工程初始化，已经引入dw-oc中的config.php
        $this->client = new OssClient(
            OSS_ACCESS_KEY_ID,
            OSS_ACCESS_KEY_SECRET,
            OSS_ENDPOINT
        );
    }

    /**
     * @return OssClient
     *
     * @throws \OSS\Core\OssException
     */
    public static function getClient(): OssClient
    {
        return (new static())->client;
    }

    public static function projectBucket(): string
    {
        return OSS_BUCKET;
    }

    /**
     * @param $method
     * @param $arguments
     *
     * @return mixed
     * @throws \OSS\Core\OssException
     */
    public static function __callStatic($method, $arguments)
    {
        return (new static)->$method(...$arguments);
    }

    public function __call($method, $arguments)
    {
        return $this->client->$method(...$arguments);
    }
}